<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0" />
    <title>美策平台</title>
    <link rel="icon" type="image/png" href="/img/icon.png">
    <link rel="stylesheet" type="text/css" href="../datepicker/jquery-ui.min.css">
    <link rel="stylesheet" type="text/css" href="../css/app.css">
    <link rel="stylesheet" type="text/css" href="../css/payType.css">
    <script type="text/javascript" src="../js/jquery.min.js"></script>

    <script type="text/javascript" src="../js/getPageId.js"></script>
    <script type="text/javascript" src="../js/alertMsg.js"></script>
    <script type="text/javascript" src="/h5/js/all.js"></script>
</head>
<body>
    <div class="orderPayTypePage">
        <div class="orderParamTitle">
            <b>保证金</b>
            <img src="../images/return.png" class="orderRtns" onclick="history.go(-1)">
        </div>
        <div style="height:1.066667rem"></div>
        <ul class="payType">
            <li data-id="alipay">
                <img src="../images/order/zhifubao.png">
                <div>支付宝</div>
                <div><img class="checked" src="../images/order/xuanz.png"></div>
            </li>
            <!--<li data-id="wechat">
                <img src="../images/order/weixin.png">
                <div>微信</div>
            </li>
            <li data-id="bank">
                <img src="../images/order/yinhangk.png">
                <div>银行卡</div>
            </li>-->
        </ul>
    </div>
    <script>
        $(function() {
            if(pageId == '' || pageId == 0){
                alertMsg("非法请求!")
                $('.payType').remove();
            }
        })

        /**
         * 本地缓存，获取    test
         * */
        function cacheGet(key){
            return JSON.parse(localStorage.getItem(key));
        }

       $('.payType li').click(function() {

           var mthis=this;
           MC.click(function(){


            var payUrl =  '/api/order/bale/pay-grap';
            $(mthis).append('<div><img class="checked" src="../images/order/xuanz.png"></div>');
            $(mthis).siblings().find('.checked').remove();
            var dataId = $(mthis).attr('data-id');
            MC.api("GeneratePayHref",{
                playType:dataId,
                out_trade_no:MC.get('out_trade_no'),
                channel:'m'
            },function(json){
                window.open(json.href,"_self");
            });
           });

            // 默认支付宝和微信已安装，后面在处理支付逻辑
           /* if(dataId === 'alipay' || dataId === 'wechat') {
                // 接入微信或者支付宝支付
                //window.location.href = 'payMoney.html'
                var userInfo = cacheGet('userInfo'); //获取用户信息
                if (userInfo==null || userInfo.token=='undefined') {
                    alertMsg("没有登录!")
                }
                $.ajax({
                    type: "post",
                    url: payUrl,
                    data: {
                        app_access :app_access,
                        token :userInfo.token,
                        oid :pageId,
                        channel :'m',
                        type :1
                    },
                    dataType: "json",
                    success: function (res) {
                        if(res.code == 200){
                            window.location.href = res.data
                        }else{
                            alertMsg(res.msg)
                        }
                    }
                });
            } else {
                // 默认银行卡绑定 isBank === 1,后端获取
                var isBank = 1;
                if(isBank) {
                    window.location.href = 'payMoney.html'
                } else {
                    window.location.href = 'payBankCard.html?isBank=' +isBank; 
                }
                
                
            }*/
        })
    </script>
</body>
</html>